﻿
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 
<title>jb-aptech毕业设计项目</TITLE>
<meta name="renderer" content="ie-comp">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../css/style.css" rel="stylesheet" type="text/css">
<script src="script/common.js"></script>
    <script src="script/validate.js"></script>
    <link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css"></link>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/vue.js"></script>
</head>
  	<script type="text/javascript">
  		function myAdd(){
  			document.sysUserForm.submit();
  		}
  	</script>
  <body>
   	<div class="page_title">权限管理 > 用户管理 > 添加系统用户</div>
    <div id="add">
   	<form name="sysUserForm" method="post" action="/CRM/sysUser.do">
   		<input type="hidden" name="method" value="addSysUser">
	   	<div class="button_bar">
	   		<button class="common_button" onclick="help('');">帮助</button>
	   		<button class="common_button" onclick="back();">返回</button>
			<button class="common_button" @click="myAdd()" type="button">保存</button>
	   	</div>
	   	<table class="query_form_table">
	   		<tr>
	   			<th>用户名</th>
	   			<td>
	   				<input type="text" v-model="sysUser.usr_name" size="20">
	   			</td>
	   		</tr>
	   		<tr>
	   			<th>密码</th>
	   			<td>
	   				<input type="password" v-model="sysUser.usr_password" size="20">
	   			</td>
            </tr>
                <tr>
	   			<th>
	   				状态
	   			</th>
	   			<td>
                    <select v-model="sysUser.usr_flag" >
                        <option value="">全部</option>
                        <option value="1">正常</option>
                        <option value="0">禁用</option>
                    </select>
	   			</td>
	   		</tr>
	   		<tr>
	   			<th>角色</th>
	   			<td>
                    <select v-model="sysUser.usr_role_id">
                        <option value="">请选择</option>
                        <option v-for="r in roles" :value="r.role_id">{{r.role_name}}</option>
                    </select>
	   			</td>
	   		</tr>
	   	</table>
   	</form>
    </div>
    <script>
        var users=new Vue({
            el:"#add",
            data:{
                sysUser:{
                    usr_name:'',
                    usr_password:'',
                    usr_flag:'',
                    usr_role_id:''
                },
                roles:[]
            },
            methods:{
                myAdd(){
                    $.getJSON("/addUser",this.sysUser,function(json){
                        if(json.code==200){
                            alert("添加成功！");
                            location="/html/~right/user/list.html";
                        }else{
                            alert("添加失败");
                            location="/html/~right/user/add.html"
                        }
                    })
                }
            },
            created(){
                $.getJSON("/queryAllRoles",function(json){
                    users.roles=json.data.role;
                })
            }
        });
    </script>
  </body>
</html>
